package com.smartfast4j.redis.test;

import org.apache.log4j.Logger;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

/**
 * Created by gacl on 2017/10/12.
 */
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "classpath:spring/spring-redisCluster.xml"})
public class redisTemplateTest2 {

    private static final Logger logger = Logger.getLogger(redisTemplateTest2.class);

    @Autowired
    private RedisTemplate redisTemplate;

    @Test
    public void testSet(){
        try {
            ValueOperations<String, String> valueOperations = redisTemplate.opsForValue();
            //设置值
            valueOperations.set("gacl", "孤傲苍狼");
            String data = valueOperations.get("gacl");
            logger.debug("data="+data);
        } catch (Exception e) {
            logger.error(e.getMessage(), e);
        }
    }

}
